﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Service.Interface;
using Domain;

namespace Clannan.Controllers
{
    public class LogController : Controller
    {
        public ILogService LogService;

       /// <summary>
       /// 获取日志列表
       /// </summary>
       /// <param name="pageIndex">页索引</param>
       /// <param name="pageSize">页大小</param>
       /// <returns></returns>
        public JsonResult GetAll(int pageIndex, int pageSize)
        {
            int pageCount;//总页数

            //获取分页数据
            IList<LogMessage> logMessage = this.LogService.LoadAllLogByPage(pageIndex, pageSize, out pageCount);

            return Json(new { Message = 1, PageCount = pageCount, LogMessage = logMessage });
        }

        /// <summary>
        /// 解决错误
        /// </summary>
        /// <param name="logID">日志ID</param>
        /// <returns></returns>
        public JsonResult Solve(int logID)
        {
            LogMessage logMessage = this.LogService.Get(logID);
            logMessage.Solve = "true";
            this.LogService.Update(logMessage);

            return Json(new { Message = 1 });
        }

        /// <summary>
        /// 删除日志
        /// </summary>
        /// <param name="logID">日志ID</param>
        /// <returns></returns>
        public JsonResult Delete(int logID)
        {
            this.LogService.Delete(logID);

            return Json(new { Message = 1 });
        }

    }
}
